package com.gy.spark.core.others

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object BroadCast {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setMaster("local").setAppName(this.getClass.getSimpleName)
    val sc = new SparkContext(conf)
    val list = List("java")
    val broadCast = sc.broadcast(list)
    val lineRDD = sc.textFile("./spark/input/words.txt")
    lineRDD.flatMap(_.split(" ")).filter { x => broadCast.value.contains(x) }.foreach {
      println
    }
    sc.stop()
  }
}